
// import { RouteObject } from "react-router-dom";


export interface MetaProps {
    keepAlive?:boolean;
    unwantedAuth?: boolean;
    title:string;
    key?:string;
}

export interface RouteObject {
    children?: RouteObject[];
    element?: React.ReactNode;
    path?: string;
    meta?: MetaProps;
}

export const matchRoute = (path: string, routes: RouteObject[] = []): RouteObject => {
    const result: RouteObject = {}
    for(const item of routes) {
        if(item.path === path) {
            return item
        }
        if(item.children && item.children.length) {
            const res = matchRoute(path, item.children);
            if(Object.keys(res).length) {
                return res
            }
        }
    }
    return result
}